#ifndef _PT2020_CONFIG_H_
#define _PT2020_CONFIG_H_


#define 		DEBUG

#define 	  Single_WR		 	 	   	      1										//在INT中断中，根据此宏来决定是单字节读，还是连续读  =0时为连续读键值
#define				__C51										1

#define 	TH_CHANNEL									0x000FFFF0UL					//触摸通道，总共20个触摸通道，BIT0--> TH1, BIT1-->TH2,依次类推		
#define 	ATRH_L 		   	        			145									  //自适应阈值，在CTRL1,07 = 1时，配置有效，根据自己项目PCB实际效果调整，越小灵敏度越高，最低不得低于20


#define   LP_WAKETHRESHOLD 		  			0x0F									//低功耗唤醒阈值默认值,	越小越容易从休眠中唤醒，最低不得低于10
#define 	LONGPRESS_RESET_TIME  			0x10									//长按复位所有触摸按键的时间默认值，此配置防止因为介质的改变导致的按键自响应而锁死，此时间到后，触摸按键重新适配当前介质.触摸恢复
#define 	INTO_LOWPOER_WAIT_TIME			0x04 	 		 						//等待进入低功耗的时间默认值
#define 	DEBOUNCE_TIMES 			 	  	  0x02									//按键消抖次数默认值
#define  	BASEUP_UPDATESPEED 		      0x05									//基值增加更新速度默认值
#define 	BASEDOWN_UPDATESPEED 		    0x32									//基值减少更新速度默认值
#define 	CMOD_CHARGING_TIME					0xA0 									//CMOD电容充电时间默认值
#define 	LP_INTERVALTIME_SCAN 			  0x3C 									//低功能模式下触摸扫描<--->休眠 间隔时间默认值
#define 	TOUCH_LED_REUSE							0x00000000UL 					//触摸与LED复用,默认熄灭，当CTRL2[3:2]配置非0时，控制相应TH复用的LED亮灭，即BIT0 = 1时，与TOUCH1复用的LED将点亮，为0时熄灭，详见规格书
#define 	TOUCH_LED_SCAN_TIME 	 	    0x0F									//触摸通道复用的LED扫描时间，设置越小越亮，最小值=5，最大40
#define 	TOUCH_CTRL1_SET 						0xF5									//功能设置1,每BIT设置功能请查阅规格书
#define	  TOUCH_CTRL2_SET 	 	 	 	    0x0C									//功能设置2,每BIT设置功能请查阅规格书










#define PT2020_CTRL1                         0x01    
#define PT2020_CTRL2                         0x02    
#define PT2020_THEN1                         0x03
#define PT2020_THEN2                         0x04
#define PT2020_THEN3                         0x05
#define PT2020_THS1                          0x06
#define PT2020_THS2                          0x07
#define PT2020_THS3                          0x08
#define PT2020_THS4                          0x09
#define PT2020_THS5                          0x0A
#define PT2020_THS6                          0x0B
#define PT2020_THS7                          0x0C
#define PT2020_THS8                          0x0D
#define PT2020_THS9                          0x0E
#define PT2020_THS10                         0x0F
#define PT2020_THS11                         0x10
#define PT2020_THS12                         0x11
#define PT2020_THS13                         0x12
#define PT2020_THS14                         0x13
#define PT2020_THS15                         0x14
#define PT2020_THS16                         0x15
#define PT2020_THS17                         0x16
#define PT2020_THS18                         0x17
#define PT2020_THS19                         0x18
#define PT2020_THS20                         0x19
#define PT2020_LPWK                          0x1A
#define PT2020_ATRH                          0x1B
#define PT2020_ATRL                          0x1C
#define PT2020_LKTIME                        0x1D
#define PT2020_LPTIME                        0x1E
#define PT2020_LEDC1                         0x1F
#define PT2020_LEDC2                         0x20
#define PT2020_LEDC3                         0x21
#define PT2020_KEYL                          0x22
#define PT2020_KEYM                          0x23
#define PT2020_KEYH                          0x24
#define PT2020_KEYIF                         0x25
#define PT2020_BUPH                          0x26
#define PT2020_BUPL                          0x27
#define PT2020_CMCT                          0x28
#define PT2020_LPST                          0x29
#define PT2020_LEDSET											   0x2A



#if __C51
extern uint8_t 	F_UART0TI;
#endif
extern uint16_t TH_KeyValue[3];



int8_t  PT2020_Touch_Channel_Config(uint32_t channel);
int8_t  PT2020_Touch_Adaptive_ATRH_L_Config(uint16_t ATR);
int8_t 	PT2020_Touch_Threshold_Manual_Set_Config(uint8_t channel,uint8_t THSx);
int8_t	PT2020_Touch_LED_Reuse_Confing(uint32_t led);
int8_t PT2020_Touch_Longpress_Time_Reset_Config(uint8_t time);
int8_t PT2020_Touch_Into_LowPower_WaitTime_Config(uint8_t time);
int8_t PT2020_Touch_LowPower_Wakeupthreshold_Config(uint8_t wake);
int8_t PT2020_Touch_Key_Debounce_times_Config(uint8_t debounce);
int8_t PT2020_Touch_BaseUp_Updatespeed_Config(uint8_t baseup);
int8_t PT2020_Touch_BaseDown_Updatespeed_Config(uint8_t basedown);
int8_t PT2020_Touch_CMOD_ChargingTime_Config(uint8_t time);
int8_t PT2020_Touch_Lowpowerscan_Intervaltime_config(uint8_t time);
int8_t PT2020_Touch_Set_ReuseLed_Output_config(uint8_t LEDSET,uint8_t LED);
int8_t PT2020_Touch_Set_LedScan_Time_config(uint8_t time);
int8_t PT2020_Touch_CTRL1_Enable_Config(uint8_t enable);
int8_t PT2020_Touch_CTRL2_Enable_Config(uint8_t enable);
int32_t PT2020_Get_Touch_KeyValue(void);
int32_t PT2020_Read_Touch_KeyValue(void);
int8_t PT2020_Touch_Init(void);
int8_t PT2020_INIT(void);

int32_t PT2020_Readback_Config_check(void);



#endif